Skip to content

[History Server] Prefer active RayCluster for RayService sessions - #5126

Open
zhuangzhewei09 wants to merge 1 commit into
ray-project:masterfrom
zhuangzhewei09:feat/select-rayservice-cluster-5065
Open

[History Server] Prefer active RayCluster for RayService sessions#5126
zhuangzhewei09 wants to merge 1 commit into
ray-project:masterfrom
zhuangzhewei09:feat/select-rayservice-cluster-5065

Conversation

@zhuangzhewei09

@zhuangzhewei09 zhuangzhewei09 commented Aug 11, 2026

Copy link
Copy Markdown

Why are these changes needed?

A RayService can own both an active and a pending RayCluster during an upgrade. The History Server previously selected the first RayCluster returned by Kubernetes, whose list order is undefined, so it could resolve a live RayService session to the pending cluster.

This change resolves live RayJob and RayService sessions from the RayCluster names stored in their status instead of listing RayClusters by owner labels. RayJobs use status.rayClusterName; RayServices prefer status.activeServiceStatus.rayClusterName and fall back to status.pendingServiceStatus.rayClusterName when the active cluster name is missing or the referenced cluster is not found.

It also grants the History Server minimal permission to get RayJobs and RayServices, and adds focused tests for exact lookup, active-to-pending fallback, missing candidates, error propagation, avoiding owner-based list calls, and historical-session fallback.

Related issue number

Part of #5065
Follow-up to #4918

Labels

  • If this PR has user-facing changes that require documentation updates at release time, I have added the doc-updates-required label.
  • If this PR contains breaking changes, I have added the breaking-change label.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(
  • Validation
    • cd historyserver && go test -race ./pkg/... ./cmd/... -parallel 4
    • cd historyserver && go vet ./pkg/historyserver

@zhuangzhewei09

Copy link
Copy Markdown
Author

@machichima I've implemented No. 1 from #5065 by preferring the active RayCluster for live RayService sessions and falling back to the pending RayCluster when the active one is unavailable. PTAL!

Comment thread historyserver/pkg/historyserver/reader.go
@zhuangzhewei09
zhuangzhewei09 force-pushed the feat/select-rayservice-cluster-5065 branch from 4652dfa to 07be803 Compare August 24, 2026 17:57

@machichima machichima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments mainly for tests. I think the test struct can be simplified after removing those test cases

Comment thread historyserver/pkg/historyserver/reader.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/reader.go
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go
Comment thread historyserver/pkg/historyserver/enter_cluster_test.go Outdated
@zhuangzhewei09
zhuangzhewei09 force-pushed the feat/select-rayservice-cluster-5065 branch from e18b68e to cf7ebd1 Compare August 31, 2026 13:32
When live cluster access is enabled, resolve RayJob and RayService
sessions from owner status instead of listing RayClusters by owner
labels. Use the RayJob cluster name directly, and check the active
RayService cluster before the pending cluster.

Grant the History Server get access to RayJobs and RayServices.
Add focused tests for status-based owner resolution, active-before-
pending selection, and owner lookup errors. Explicitly enable live
clusters in the test fixture to respect the default-off behavior.

Refs ray-project#5065.

Signed-off-by: zhuangzhewei09 <zhuangzhewei09@dingtalk.com>
@zhuangzhewei09
zhuangzhewei09 force-pushed the feat/select-rayservice-cluster-5065 branch from cf7ebd1 to 13bfca7 Compare September 3, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants